home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Codecs / DrawTextCodec / DrawTextDecompress.c < prev   
Encoding:
C/C++ Source or Header  |  1992-06-09  |  1.4 KB  |  71 lines  |  [TEXT/MPS ]

  1. /*
  2.  
  3.     Written by:    Mark Krueger
  4.  
  5.     Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  6.  
  7. */
  8.  
  9.  
  10. #include    <QuickDraw.h>
  11. #include    "ImageCompression.h"
  12.  
  13. #include    "DrawTextCodec.h"
  14.  
  15.  
  16. /*
  17.  
  18.     decompress bheight strips ( of bwidth blocks ) of data. Each block is represented 
  19.     by one character of the font from compressed data. Font is assumed to be the same
  20.     as that used in compression - ( font type style and size could be included in a header
  21.     before the actual compressed data if we wanted to be truly flexible, but for a half-hour
  22.      demo hack we dont wanna be) 
  23.     
  24.     destination must be 1-bit/pixel.
  25.     
  26.     should be called in 32-bit mode.
  27.     
  28. */
  29.  
  30. long
  31. Decompress(unsigned char *baseAddr,short rowBytes,short bwidth,short bheight,char *dataPtr)
  32. {
  33.  
  34.     char            *startDataPtr;
  35.     unsigned char     *rp,*bp;
  36.     short            i,x,y;
  37.     
  38.     startDataPtr = dataPtr;                /* remember where we started from */
  39.  
  40.     TextSize(FONT_SIZE);
  41.     TextFont(FONT_ID);
  42.     for ( y=0; y <  bheight; y++ ) {
  43.         rp = baseAddr;
  44.         for (x=0; x < bwidth; x++) {
  45.             bp = rp;
  46.             for ( i=0; i < FONT_HEIGHT; i++ ) {
  47.                 *bp = 0;
  48.                 bp += rowBytes;
  49.             }
  50.             MoveTo(x*FONT_WIDTH,BASE_LINE + y*FONT_HEIGHT);
  51.             DrawChar(*dataPtr++);
  52.             rp++;
  53.             if ( x < bwidth ) {
  54.                 bp = rp;
  55.                 for ( i=0; i < FONT_HEIGHT; i++ ) {
  56.                     *bp = 0;
  57.                     bp += rowBytes;
  58.                 }
  59.             }
  60.         }
  61.         baseAddr += rowBytes * FONT_HEIGHT;
  62.     } 
  63.     return (dataPtr - startDataPtr);    
  64.     
  65.  
  66. }
  67.  
  68.  
  69.  
  70.  
  71.